package com.nxj.utils;

import com.nxj.annotation.Autowired;
import com.nxj.annotation.Component;

import java.sql.SQLException;

@Component
public class TransactionManager {

    @Autowired
    private ConnectionUtils connectionUtils;

    /*
    public void setConnectionUtils(ConnectionUtils connectionUtils) {
        this.connectionUtils = connectionUtils;
    }*/

    public void beginTransaction() throws SQLException {
        this.connectionUtils.getConnection().setAutoCommit(false);
    }

    public void commit() throws SQLException {
        this.connectionUtils.getConnection().commit();
    }

    public void roll() throws SQLException {
        this.connectionUtils.getConnection().rollback();
    }
}
